package org.rowan.infovis.soccer;

import javax.media.opengl.GL;
import javax.media.opengl.glu.GLU;
import javax.media.opengl.glu.GLUquadric;

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 *
 * @author eeburns
 */
public class PlayerViewer
{
    private PlayerMenu playerMenu;
    private PlayerCategoryNav nav;

    private Player player1;
    private Player player2;

    private TeamManager teamManager;

    public PlayerViewer(TeamManager tm, StateManager s) {
        this.teamManager = tm;
        this.playerMenu = new PlayerMenu(tm,s);
        this.player1 = new Player();
        this.player2 = new Player();
        this.nav = new PlayerCategoryNav();
    }

    public void draw(GL gl)
    {
//        player1 = new Player(1, 26, 51, 76, 1, 26);
//        player2 = new Player(1, 26, 51, 76, 1, 26);

        

        gl.glPushMatrix();
        gl.glTranslated(475, 230, 0);
        nav.draw(gl, 475, 230);
        gl.glPopMatrix();

        gl.glPushMatrix();
        gl.glTranslated(145, 75, 0);
        playerMenu.draw(gl, 145, 75);
        gl.glPopMatrix();

        gl.glPushMatrix();
        gl.glScaled(.95, .95, .95);
       /// gl.glTranslated(-250, 75, 0);
        player1.draw(gl, 150, 500, teamManager.getCurrentTeam().getCurrentPlayer());
        gl.glPopMatrix();

        gl.glPushMatrix();
        gl.glScaled(.95, .95, .95);
        ///gl.glTranslated(250, 75, 0);
        player2.draw(gl, 650, 500, teamManager.getSecondCurrentTeam().getSecondCurrentPlayer());
        gl.glPopMatrix();
        
        //Fill in the player body part colors
        switch(nav.getMode())
        {
            case 1:
                //Current Player (LEFT)
                player1.setLegsColorValue(teamManager.getCurrentTeam().getCurrentPlayer().getFluencyData(1));
                player1.setHeadColorValue(teamManager.getCurrentTeam().getCurrentPlayer().getFluencyData(2));
                player1.setArmsColorValue(teamManager.getCurrentTeam().getCurrentPlayer().getFluencyData(3));
                player1.setChestColorValue(teamManager.getCurrentTeam().getCurrentPlayer().getFluencyData(4));
                player1.setTorsoColorValue(teamManager.getCurrentTeam().getCurrentPlayer().getFluencyData(5));
                player1.setSoccerBallLocationValue(teamManager.getCurrentTeam().getCurrentPlayer().getFluencyData(6));
                player1.setFootColorValue(teamManager.getCurrentTeam().getCurrentPlayer().getFluencyData(7));
                player1.setSoccerBallColorValue(teamManager.getCurrentTeam().getCurrentPlayer().getFluencyData(8));

                //Second Player (RIGHT)
                player2.setLegsColorValue(teamManager.getSecondCurrentTeam().getSecondCurrentPlayer().getFluencyData(1));
                player2.setHeadColorValue(teamManager.getSecondCurrentTeam().getSecondCurrentPlayer().getFluencyData(2));
                player2.setArmsColorValue(teamManager.getSecondCurrentTeam().getSecondCurrentPlayer().getFluencyData(3));
                player2.setChestColorValue(teamManager.getSecondCurrentTeam().getSecondCurrentPlayer().getFluencyData(4));
                player2.setTorsoColorValue(teamManager.getSecondCurrentTeam().getSecondCurrentPlayer().getFluencyData(5));
                player2.setSoccerBallLocationValue(teamManager.getSecondCurrentTeam().getSecondCurrentPlayer().getFluencyData(6));
                player2.setFootColorValue(teamManager.getSecondCurrentTeam().getSecondCurrentPlayer().getFluencyData(7));
                player2.setSoccerBallColorValue(teamManager.getSecondCurrentTeam().getSecondCurrentPlayer().getFluencyData(8));
                break;
            case 2:
                //Current Player (LEFT)
                player1.setLegsColorValue(teamManager.getCurrentTeam().getCurrentPlayer().getCoordinationData(1));
                player1.setHeadColorValue(teamManager.getCurrentTeam().getCurrentPlayer().getCoordinationData(2));
                player1.setArmsColorValue(teamManager.getCurrentTeam().getCurrentPlayer().getCoordinationData(3));
                player1.setChestColorValue(teamManager.getCurrentTeam().getCurrentPlayer().getCoordinationData(4));
                player1.setTorsoColorValue(teamManager.getCurrentTeam().getCurrentPlayer().getCoordinationData(5));
                player1.setSoccerBallLocationValue(teamManager.getCurrentTeam().getCurrentPlayer().getCoordinationData(6));
                player1.setFootColorValue(teamManager.getCurrentTeam().getCurrentPlayer().getCoordinationData(7));
                player1.setSoccerBallColorValue(teamManager.getCurrentTeam().getCurrentPlayer().getCoordinationData(8));

                //Second Player (RIGHT)
                player2.setLegsColorValue(teamManager.getSecondCurrentTeam().getSecondCurrentPlayer().getCoordinationData(1));
                player2.setHeadColorValue(teamManager.getSecondCurrentTeam().getSecondCurrentPlayer().getCoordinationData(2));
                player2.setArmsColorValue(teamManager.getSecondCurrentTeam().getSecondCurrentPlayer().getCoordinationData(3));
                player2.setChestColorValue(teamManager.getSecondCurrentTeam().getSecondCurrentPlayer().getCoordinationData(4));
                player2.setTorsoColorValue(teamManager.getSecondCurrentTeam().getSecondCurrentPlayer().getCoordinationData(5));
                player2.setSoccerBallLocationValue(teamManager.getSecondCurrentTeam().getSecondCurrentPlayer().getCoordinationData(6));
                player2.setFootColorValue(teamManager.getSecondCurrentTeam().getSecondCurrentPlayer().getCoordinationData(7));
                player2.setSoccerBallColorValue(teamManager.getSecondCurrentTeam().getSecondCurrentPlayer().getCoordinationData(8));
                break;
            case 3:
                //Current Player (LEFT)
                player1.setLegsColorValue(teamManager.getCurrentTeam().getCurrentPlayer().getEasinessData(1));
                player1.setHeadColorValue(teamManager.getCurrentTeam().getCurrentPlayer().getEasinessData(2));
                player1.setArmsColorValue(teamManager.getCurrentTeam().getCurrentPlayer().getEasinessData(3));
                player1.setChestColorValue(teamManager.getCurrentTeam().getCurrentPlayer().getEasinessData(4));
                player1.setTorsoColorValue(teamManager.getCurrentTeam().getCurrentPlayer().getEasinessData(5));
                player1.setSoccerBallLocationValue(teamManager.getCurrentTeam().getCurrentPlayer().getEasinessData(6));
                player1.setFootColorValue(teamManager.getCurrentTeam().getCurrentPlayer().getEasinessData(7));
                player1.setSoccerBallColorValue(teamManager.getCurrentTeam().getCurrentPlayer().getEasinessData(8));

                //Second Player (RIGHT)
                player2.setLegsColorValue(teamManager.getSecondCurrentTeam().getSecondCurrentPlayer().getEasinessData(1));
                player2.setHeadColorValue(teamManager.getSecondCurrentTeam().getSecondCurrentPlayer().getEasinessData(2));
                player2.setArmsColorValue(teamManager.getSecondCurrentTeam().getSecondCurrentPlayer().getEasinessData(3));
                player2.setChestColorValue(teamManager.getSecondCurrentTeam().getSecondCurrentPlayer().getEasinessData(4));
                player2.setTorsoColorValue(teamManager.getSecondCurrentTeam().getSecondCurrentPlayer().getEasinessData(5));
                player2.setSoccerBallLocationValue(teamManager.getSecondCurrentTeam().getSecondCurrentPlayer().getEasinessData(6));
                player2.setFootColorValue(teamManager.getSecondCurrentTeam().getSecondCurrentPlayer().getEasinessData(7));
                player2.setSoccerBallColorValue(teamManager.getSecondCurrentTeam().getSecondCurrentPlayer().getEasinessData(8));
                break;
            case 4:
                //Current Player (LEFT)
                player1.setLegsColorValue(teamManager.getCurrentTeam().getCurrentPlayer().getRapidityData(1));
                player1.setHeadColorValue(teamManager.getCurrentTeam().getCurrentPlayer().getRapidityData(2));
                player1.setArmsColorValue(teamManager.getCurrentTeam().getCurrentPlayer().getRapidityData(3));
                player1.setChestColorValue(teamManager.getCurrentTeam().getCurrentPlayer().getRapidityData(4));
                player1.setTorsoColorValue(teamManager.getCurrentTeam().getCurrentPlayer().getRapidityData(5));
                player1.setSoccerBallLocationValue(teamManager.getCurrentTeam().getCurrentPlayer().getRapidityData(6));
                player1.setFootColorValue(teamManager.getCurrentTeam().getCurrentPlayer().getRapidityData(7));
                player1.setSoccerBallColorValue(teamManager.getCurrentTeam().getCurrentPlayer().getRapidityData(8));

                //Second Player (RIGHT)
                player2.setLegsColorValue(teamManager.getSecondCurrentTeam().getSecondCurrentPlayer().getRapidityData(1));
                player2.setHeadColorValue(teamManager.getSecondCurrentTeam().getSecondCurrentPlayer().getRapidityData(2));
                player2.setArmsColorValue(teamManager.getSecondCurrentTeam().getSecondCurrentPlayer().getRapidityData(3));
                player2.setChestColorValue(teamManager.getSecondCurrentTeam().getSecondCurrentPlayer().getRapidityData(4));
                player2.setTorsoColorValue(teamManager.getSecondCurrentTeam().getSecondCurrentPlayer().getRapidityData(5));
                player2.setSoccerBallLocationValue(teamManager.getSecondCurrentTeam().getSecondCurrentPlayer().getRapidityData(6));
                player2.setFootColorValue(teamManager.getSecondCurrentTeam().getSecondCurrentPlayer().getRapidityData(7));
                player2.setSoccerBallColorValue(teamManager.getSecondCurrentTeam().getSecondCurrentPlayer().getRapidityData(8));
                break;
            case 5:
                //Current Player (LEFT)
                player1.setLegsColorValue(teamManager.getCurrentTeam().getCurrentPlayer().getFootMistakesData(1));
                player1.setHeadColorValue(teamManager.getCurrentTeam().getCurrentPlayer().getFootMistakesData(2));
                player1.setArmsColorValue(teamManager.getCurrentTeam().getCurrentPlayer().getFootMistakesData(3));
                player1.setChestColorValue(teamManager.getCurrentTeam().getCurrentPlayer().getFootMistakesData(4));
                player1.setTorsoColorValue(teamManager.getCurrentTeam().getCurrentPlayer().getFootMistakesData(5));
                player1.setSoccerBallLocationValue(teamManager.getCurrentTeam().getCurrentPlayer().getFootMistakesData(6));
                player1.setFootColorValue(teamManager.getCurrentTeam().getCurrentPlayer().getFootMistakesData(7));
                player1.setSoccerBallColorValue(teamManager.getCurrentTeam().getCurrentPlayer().getFootMistakesData(8));

                //Second Player (RIGHT)
                player2.setLegsColorValue(teamManager.getSecondCurrentTeam().getSecondCurrentPlayer().getFootMistakesData(1));
                player2.setHeadColorValue(teamManager.getSecondCurrentTeam().getSecondCurrentPlayer().getFootMistakesData(2));
                player2.setArmsColorValue(teamManager.getSecondCurrentTeam().getSecondCurrentPlayer().getFootMistakesData(3));
                player2.setChestColorValue(teamManager.getSecondCurrentTeam().getSecondCurrentPlayer().getFootMistakesData(4));
                player2.setTorsoColorValue(teamManager.getSecondCurrentTeam().getSecondCurrentPlayer().getFootMistakesData(5));
                player2.setSoccerBallLocationValue(teamManager.getSecondCurrentTeam().getSecondCurrentPlayer().getFootMistakesData(6));
                player2.setFootColorValue(teamManager.getSecondCurrentTeam().getSecondCurrentPlayer().getFootMistakesData(7));
                player2.setSoccerBallColorValue(teamManager.getSecondCurrentTeam().getSecondCurrentPlayer().getFootMistakesData(8));
                break;
            case 6:
                //Current Player (LEFT)
                player1.setLegsColorValue(teamManager.getCurrentTeam().getCurrentPlayer().getTorsoMistakesData(1));
                player1.setHeadColorValue(teamManager.getCurrentTeam().getCurrentPlayer().getTorsoMistakesData(2));
                player1.setArmsColorValue(teamManager.getCurrentTeam().getCurrentPlayer().getTorsoMistakesData(3));
                player1.setChestColorValue(teamManager.getCurrentTeam().getCurrentPlayer().getTorsoMistakesData(4));
                player1.setTorsoColorValue(teamManager.getCurrentTeam().getCurrentPlayer().getTorsoMistakesData(5));
                player1.setSoccerBallLocationValue(teamManager.getCurrentTeam().getCurrentPlayer().getTorsoMistakesData(6));
                player1.setFootColorValue(teamManager.getCurrentTeam().getCurrentPlayer().getTorsoMistakesData(7));
                player1.setSoccerBallColorValue(teamManager.getCurrentTeam().getCurrentPlayer().getTorsoMistakesData(8));

                //Second Player (RIGHT)
                player2.setLegsColorValue(teamManager.getSecondCurrentTeam().getSecondCurrentPlayer().getTorsoMistakesData(1));
                player2.setHeadColorValue(teamManager.getSecondCurrentTeam().getSecondCurrentPlayer().getTorsoMistakesData(2));
                player2.setArmsColorValue(teamManager.getSecondCurrentTeam().getSecondCurrentPlayer().getTorsoMistakesData(3));
                player2.setChestColorValue(teamManager.getSecondCurrentTeam().getSecondCurrentPlayer().getTorsoMistakesData(4));
                player2.setTorsoColorValue(teamManager.getSecondCurrentTeam().getSecondCurrentPlayer().getTorsoMistakesData(5));
                player2.setSoccerBallLocationValue(teamManager.getSecondCurrentTeam().getSecondCurrentPlayer().getTorsoMistakesData(6));
                player2.setFootColorValue(teamManager.getSecondCurrentTeam().getSecondCurrentPlayer().getTorsoMistakesData(7));
                player2.setSoccerBallColorValue(teamManager.getSecondCurrentTeam().getSecondCurrentPlayer().getTorsoMistakesData(8));
                break;
           case 7:
                //Current Player (LEFT)
                player1.setLegsColorValue(teamManager.getCurrentTeam().getCurrentPlayer().getSlowExecutionData(1));
                player1.setHeadColorValue(teamManager.getCurrentTeam().getCurrentPlayer().getSlowExecutionData(2));
                player1.setArmsColorValue(teamManager.getCurrentTeam().getCurrentPlayer().getSlowExecutionData(3));
                player1.setChestColorValue(teamManager.getCurrentTeam().getCurrentPlayer().getSlowExecutionData(4));
                player1.setTorsoColorValue(teamManager.getCurrentTeam().getCurrentPlayer().getSlowExecutionData(5));
                player1.setSoccerBallLocationValue(teamManager.getCurrentTeam().getCurrentPlayer().getSlowExecutionData(6));
                player1.setFootColorValue(teamManager.getCurrentTeam().getCurrentPlayer().getSlowExecutionData(7));
                player1.setSoccerBallColorValue(teamManager.getCurrentTeam().getCurrentPlayer().getSlowExecutionData(8));

                //Second Player (RIGHT)
                player2.setLegsColorValue(teamManager.getSecondCurrentTeam().getSecondCurrentPlayer().getSlowExecutionData(1));
                player2.setHeadColorValue(teamManager.getSecondCurrentTeam().getSecondCurrentPlayer().getSlowExecutionData(2));
                player2.setArmsColorValue(teamManager.getSecondCurrentTeam().getSecondCurrentPlayer().getSlowExecutionData(3));
                player2.setChestColorValue(teamManager.getSecondCurrentTeam().getSecondCurrentPlayer().getSlowExecutionData(4));
                player2.setTorsoColorValue(teamManager.getSecondCurrentTeam().getSecondCurrentPlayer().getSlowExecutionData(5));
                player2.setSoccerBallLocationValue(teamManager.getSecondCurrentTeam().getSecondCurrentPlayer().getSlowExecutionData(6));
                player2.setFootColorValue(teamManager.getSecondCurrentTeam().getSecondCurrentPlayer().getSlowExecutionData(7));
                player2.setSoccerBallColorValue(teamManager.getSecondCurrentTeam().getSecondCurrentPlayer().getSlowExecutionData(8));
                break;
        }
        gl.glPolygonMode(GL.GL_FRONT_AND_BACK, GL.GL_FILL);
    }

    public void mouseReleased(int x, int y) {
        playerMenu.mouseReleased(x, y);
        nav.mouseReleased(x, y);
    }

    public void mouseMoved(int x, int y) {
        playerMenu.mouseMoved(x, y);
        nav.mouseMoved(x, y);
    }
}
